<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
use App\Models\Setting;

class SeedSettingsData extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $settings = [
            [
                'title' => '站点名称',
                'variate' => 'site_title',
                'type' => 'text',
                'group' => 'site',
                'value' => '织梦行云',
                'options' => null,
                'remark' => '网站前台站点名称',
            ], [
                'title' => '联系邮箱',
                'variate' => 'contact_email',
                'type' => 'text',
                'group' => 'site',
                'value' => '313097973@qq.com',
                'options' => null,
                'remark' => '',
            ], [
                'title' => 'SEO 关键字',
                'variate' => 'seo_keyword',
                'type' => 'textarea',
                'group' => 'seo',
                'value' => 'Laravel,ThinkPHP,PHP,论坛,话题,分享,教程,问答,公告',
                'options' => null,
                'remark' => '',
            ], [
                'title' => 'SEO 描述',
                'variate' => 'seo_description',
                'type' => 'textarea',
                'group' => 'seo',
                'value' => 'Laravel,ThinkPHP,PHP,论坛,话题,分享,教程,问答,公告',
                'options' => null,
                'remark' => '',
            ], [
                'title' => '技术支持',
                'variate' => 'powered_by',
                'type' => 'text',
                'group' => 'site',
                'value' => 'ELLa123',
                'options' => null,
                'remark' => '',
            ], [
                'title' => 'ICP备案',
                'variate' => 'icp',
                'type' => 'text',
                'group' => 'site',
                'value' => '黔ICP备15014794号',
                'options' => null,
                'remark' => '',
            ], [
                'title' => '调试',
                'variate' => 'app_debug',
                'type' => 'switch',
                'group' => 'develop',
                'value' => 1,
                'options' => null,
                'remark' => '',
            ], [
                'title' => '环境',
                'variate' => 'app_env',
                'type' => 'select',
                'group' => 'env',
                'value' => 'local',
                'options' => json_encode(['local' => '本地开发环境', 'production' => '生产部署环境']),
                'remark' => '',
            ],
        ];

        // DB::table('settings')->insert($settings);
        Setting::upsert($settings, ['variate',], ['title', 'type', 'value', 'options', 'remark',]);

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        DB::table('settings')->truncate();
    }
}
